export function getCurrentDate(format = 'YYYY-MM-DD') {
    const now = new Date();
    const year = now.getFullYear();
    const month = now.getMonth() + 1;
    const day = now.getDate();

    switch (format) {
        case 'YYYY-MM-DD':
            return `${year}-${month.toString().padStart(2, '0')}-${day.toString().padStart(2, '0')}`;
        case 'YYYY/MM/DD':
            return `${year}/${month.toString().padStart(2, '0')}/${day.toString().padStart(2, '0')}`;
        case 'DD-MM-YYYY':
            return `${day.toString().padStart(2, '0')}-${month.toString().padStart(2, '0')}-${year}`;
        default:
            return `${year}-${month.toString().padStart(2, '0')}-${day.toString().padStart(2, '0')}`;
    }
}
export function updateCurrentTime() {
    // 创建一个新的 Date 对象
    const now = new Date();
    // 获取年月日时分秒
    const year = now.getFullYear();
    const month = now.getMonth() + 1;
    const day = now.getDate();
    const hours = now.getHours();
    const minutes = now.getMinutes();
    const seconds = now.getSeconds();
    // 辅助函数，用于为一位数的数字添加前导零
    function padTo2Digits(num) {
        return num.toString().padStart(2, "0");
    }
    // 格式化时间字符串
    return `${year}-${padTo2Digits(month)}-${padTo2Digits(
        day
    )} ${padTo2Digits(hours)}:${padTo2Digits(minutes)}:${padTo2Digits(
        seconds
    )}`;
}